package org.finjic.annotated.processor.parser;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

/**
 * User: Taras
 * Date: 18.11.12
 * Time: 15:37
 */
public class ConfigFileParser {
    private String configFile;

    public ConfigFileParser(String configFile) {
        this.configFile = configFile;
    }

    public String getPackageName() {
        AnnotationSaxHandler handler = new AnnotationSaxHandler();
        try {
            SAXParserFactory factory = SAXParserFactory.newInstance();
            SAXParser saxParser = factory.newSAXParser();
            saxParser.parse(configFile, handler);
        } catch (Exception e) {
            throw new RuntimeException(e.getCause());
        }
        return handler.getPackageName();
    }
}
